<?include_once('conn.php');?>
<html>
<head>
<?include_once('inc_head.php');?>
<?
$act=$_GET['act'];
$ListName=TABLE_C."vote_series"; //要操作的表名
switch($act){

//''''''''''''''''''''''''''''''''''''''''''''''''''''修改'''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "editok";
	$id=intval($_POST["id"]);
	$name=rq('name');
	$price=intval(rq('price'));
	$payment=intval(rq('payment'));
	$active=intval(rq('active'));
	$type=rq('type');
	$rule=rq('rule');
	$evaluate_a=rq('evaluate_a');
	$evaluate_b=rq('evaluate_b');
	
	$cmd="update $ListName set name='$name',price=$price,rule='$rule',payment=$payment,active=$active,evaluate_a='$evaluate_a',evaluate_b='$evaluate_b',type='$type' where id=$id";
	// exit;
	if(mysql_query($cmd) or die(mysql_error())){
	gourl('修改成功！',$cururl);
	}
	exit;
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?local("问卷管理");?>
<div id="intro">

<!-- ////////////////////////////////////////////////////////////////////////////////  编辑状态   ///////////////////////////////////////////////////////////////////////////// -->
<!-- ////////////////////////////////////////////////////////////////////////////////  编辑状态   ///////////////////////////////////////////////////////////////////////////// -->
<!-- ////////////////////////////////////////////////////////////////////////////////  编辑状态   ///////////////////////////////////////////////////////////////////////////// -->
<?
	if(strlen($act)==0){
	$id=intval($_GET['id']);
	$type=intval($_GET['type']);
	$cmd="select * from $ListName where id=$id";
	$rs=mysql_query($cmd);
	$data=mysql_fetch_assoc($rs);
?>
	<div class="local2"><b>修改分类</b></div>
	<form name="editform" action="?act=editok" method="post">
		<table class="table_form" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
			<td width=100>ID</td>
			<td width=""><input type=text name="id" class="form-control" value="<?echo $data["id"]?>" size=4 readonly></td>
			</tr>
			<tr>
			<td>名称</td>
			<td><input type=text name="name" class=" :required form-control" value="<?echo $data["name"]?>"></td>
			</tr>
			<!--一级分类才显示主要设置-->
			<? if ($type == 1){ ?>
				<tr>
					<td>价格</td>
					<td><input type=text name="price" class=" :required form-control" value="<?echo $data["price"]?>" size=10></td>
				</tr>
				<tr>
					<td>问卷类型</td>
					<td>
						<select name="type" id="type" >
						<?
						$type_arr = Array();
						array_push($type_arr,'personal');
						array_push($type_arr,'company');
						foreach ($type_arr as $key => $value) {
							if($value==$data['type']){
								echo "<option selected value=\"$value\">$value</option>";
							}else{
								echo "<option value=\"$value\">$value</option>";
							}
						}
						?>
						</select>
					</td>
				</tr>
				<tr>
					<td class="allleftcar"> 是否收费 </td>
					<td>
						<? if ($data['payment']) {?>
							<label class="el-checkbox">
								<input type="checkbox" name="payment"  id="chk-islock" value="1" checked><span  class="el-checkbox-style"></span>
							</label>
						<?}else{?>
							<label class="el-checkbox">
								<input type="checkbox" name="payment"  id="chk-islock" value="1"><span  class="el-checkbox-style"></span>
							</label>
						<?}?>
						请谨慎使用此处
					</td>
				</tr>
				<tr>
					<td class="allleftcar"> 是否开启 </td>
					<td>
						<? if ($data['active']) {?>
							<label class="el-checkbox">
								<input type="checkbox" name="active"  id="chk-islock" value="1" checked><span  class="el-checkbox-style"></span>
							</label>
						<?}else{?>
							<label class="el-checkbox">
								<input type="checkbox" name="active"  id="chk-islock" value="1"><span  class="el-checkbox-style"></span>
							</label>
						<?}?>
					</td>
				</tr>
				<?}?>
			<!--二级分类才显示计分规则他评语-->
			<? if ($type == 2){ ?>
				<tr>
					<td>规则</td>
					<td><input type=text name="rule" class=" :required form-control" value="<?echo $data["rule"]?>" size=50></td>
				</tr>
				<tr>
					<td> 评语A </td>
					<td> <?myEditor($editor,'evaluate_a',$data['evaluate_a'],$editor_width,$editor_height);?> </td>
				</tr>
				<tr>
					<td> 评语B </td>
					<td> <?myEditor($editor,'evaluate_b',$data['evaluate_b'],$editor_width,$editor_height);?> </td>
				</tr>
			<?}?>
			<!-- 提交 -->
			<tr>
				<td> </td>
				<td><button type="submit" class="btn btn-primary">保存</button></td>
			</tr>
		</table>
	</form>
<? }?>
</div>
<? include('inc_foot.php');?>
</body>
</html>